#ifndef SPI_9BIT_H
#define SPI_9BIT_H

#include <stdint.h>

// SC18IS602B I2C Address (可根据实际硬件连接调整)
#define SC18IS602B_ADDR     0x28

// Function IDs
#define FUNC_SPI_CONFIG     0xF0
#define FUNC_SPI_TRANSFER   0x01    // 单字节传输
#define FUNC_SPI_WRITE_BUF  0x02    // 多字节连续传输

// SPI Configuration
#define SPI_CONFIG_9BIT     0x01    // 9-bit data length
#define SPI_CLK_1843KHZ     0x00    // Clock rate
#define SPI_MODE_0          0x00    // CPOL=0, CPHA=0

// Status
#define SPI_SUCCESS         0
#define SPI_ERROR          -1

// Function declarations
int spi_init(void);
int spi_write_9bit(uint16_t *data, uint8_t len);
int spi_read_9bit(uint16_t *data, uint8_t len);
int spi_transfer_9bit(uint16_t *tx_data, uint16_t *rx_data, uint8_t len);

#endif /* SPI_9BIT_H */ 